package com.winspread.mvvm.base.vm

import android.app.Activity
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import com.winspread.mvvm.base.m.BaseViewModel
import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type

open class BaseNotFragment<ViewDataBinding : androidx.databinding.ViewDataBinding?>(
    private val layoutId: Int,
) : Fragment() {


    val binding: ViewDataBinding by lazy {
        DataBindingUtil.inflate(LayoutInflater.from(context), layoutId, null, false)
    }


      var mActivity :Activity? = null


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = binding?.root
        binding?.lifecycleOwner = this
        initView()
        initData(savedInstanceState)
        // oberver 统一处理
        onOberver()
        // 统一监听事件
        initListenter()
        return view
    }


    override fun onAttach(context: Context) {
        super.onAttach(context)
        mActivity =  activity
    }


    open fun initView() {

    }

    open fun initData(savedInstanceState: Bundle?) {

    }

    open fun onOberver() {

    }

    open fun initListenter() {

    }
}